<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<%@taglib uri="/struts-tags" prefix="s" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Welcome</title>
<link rel="stylesheet" href="Style.css" type="text/css" />
</head>

<script language="JavaScript">
	function idandtitleunres(id) {
		document.getElementById("idUnres1").value=id;
	}
</script>
<script language="JavaScript">
	function idandtitleunresdetails(id){
		document.getElementById("idUnresDetails").value=id;
	}
</script>

<script language="JavaScript">
	function idandtitleres(id) {
		document.getElementById("idRes1").value=id;
	}
</script>
<script language="JavaScript">
	function idandtitleresdetails(id){
		document.getElementById("idResDetails").value=id;
	}
</script>
<script language="JavaScript">
    function leavecomment(idtable, id) {
        var item_tr = document.getElementById(idtable);
        document.getElementById("idRes1").value=id;
        
        if (item_tr) { 
	        if (item_tr.style.display == "none") {
		        item_tr.style.display = "";

	        } else {
		        item_tr.style.display = "none";
	        }
        }
    }
	
</script>

<body>
<s:if test="#session.loggedin != 'true'">
            <jsp:forward page="/index.jsp" />
        </s:if>
<h1>Reviewer: <s:property value="#session.user.getName()" /> <s:property value="#session.user.getSecond_name()" /></h1>
			<p align="right"><s:url id="link" action="logout" >
			</s:url>
			<s:a href="%{link}" >Logout</s:a></p>
<hr>

<h4>Notifications: </h4> 

<br/>
<s:if test="notifications.isEmpty()" >
	<table>
		<tr>
			<td>
				No notifications :)
			</td>
		</tr>	
	</table> 
</s:if>
<s:else>

	<table border="1">

		<s:iterator value="notifications" status="itStatus">
		<tr>
			<td align="center">
				<s:property value="getId()" />
			</td>
			<td align="center">
				<s:property value="getDate()" />
			</td>
			<td align="center">
				<s:property value="getNote()" />
			</td>
		</tr>
		</s:iterator>
	</table>
	
</s:else>
<br />
<hr>
	<jsp:include page="header.jspf"></jsp:include>
<hr>
<br />
<h3>Unresolved Publications</h3>
<br />
	<s:form action="showUnresolved">
		<s:submit value="Consult" ></s:submit>
		</s:form>
			<table border="1">
			<s:if test="foundUnres==true">
				<tr>
					<td><b>IdArticle</b></td>
					<td><b>Date</b></td>
					<td><b>Mark</b></td>
					<td><b>Evaluate</b></td>
					<td><b>Details</b></td>
					<td><b>Download(PDF)</b></td>
				</tr>
			</s:if>
			<s:iterator value="articleReviewList" status="itStatus">
				<tr>
					<td><s:property value="getIdArticle()" /></td>
					<td><s:property value="getReview_date()" /></td>
					<td><s:property value="getMark()" /></td>
					<td>
					
						<s:url id="link" action="gotoEvaluation" >
							<s:param name="id_toEvaluate" ><s:property value="getIdArticle()" /></s:param>
							</s:url>
						<s:a href="%{link}" >Yes</s:a>					
					
					</td>
					<td>
						<s:url id="link" action="articleDetailsUnRes" >
							<s:param name="idDetailsUnRes" ><s:property value="getIdArticle()" /></s:param>
							</s:url>
						<s:a href="%{link}" >Details</s:a>
					
					</td>
					<td><a href='<s:url action="download"><s:param name="idArticle" ><s:property value="getIdArticle()" /> </s:param></s:url>'>Get PDF</a>
				</tr>
			</s:iterator>
		</table>

<br />
<h3>Reviewed Publications</h3>
<br />
	<s:form action="showResolved">
		<s:submit value="Consult" ></s:submit>
		</s:form>
			<table border="1">
			<s:if test="foundRes==true">
				<tr>
					<td><b>Date</b></td>
					<td><b>IdArticle</b></td>
					<td><b>Mark</b></td>
					<td><b>Comment</b></td>
					<td><b>Leave a Comment?</b></td>
					<td><b>Details</b></td>
					<td><b>Download(PDF)</b></td>
				</tr>
			</s:if>
			<s:iterator value="reviewList" status="itStatus">
				<tr>
					<td><s:property value="getReview_date()" /></td>
					<td><s:property value="getIdArticle()" /></td>
					<td><s:property value="getMark()" /></td>
					<td><s:property value="getComment()" /></td>
					<td><a href="javascript:leavecomment('comment_t','<s:property value="getIdArticle()" />')">Yes</a></td>
					<td>	
						<s:url id="link" action="articleDetailsRes" >
						<s:param name="idDetailsRes" ><s:property value="getIdArticle()" /></s:param>
						</s:url>
						<s:a href="%{link}" >Details</s:a>
					</td>
					<td><a href='<s:url action="download"><s:param name="idArticle" ><s:property value="getIdArticle()" /> </s:param></s:url>'>Get PDF</a>
				</tr>
			</s:iterator>
		</table>
		<div id="comment_t" style="display:none; border-top-style:none;">
			<table >
				<s:form action="commentPublication">
					<s:hidden id="idRes1" name="idres" />
					<s:textarea name="commenttext" label="Write a comment" cols="30" rows="5"/>
					<s:submit name="setComment" value="Send Comment" />
				</s:form>
			</table>
		</div>
		<div style="display:none;">
		<s:form action="articleDetailsRes">
			<s:textfield id="idResDetails" name="idDetailsRes" label="IdArticle"  />
			<s:submit name="viewDetailsRes" value="View Details" />
		</s:form>
		</div>


</body>
</html>